
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package jfxstagesize;

import java.awt.Dimension;
import java.awt.Toolkit;
import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 *
 * @author kylin
 */
public class JFXStageSize extends Application {
    public Stage window = null;
    private Group root = new Group();
    private BorderPane content = null;
    
    private double maxwidth,maxheight,prewidth=1000,preheight=500;
    private boolean fmax,fmin;
    private Scene scene;
    @Override
    public void start(Stage primaryStage) {
        Toolkit tk=Toolkit.getDefaultToolkit();
        Dimension screen=tk.getScreenSize();
        maxwidth=screen.getWidth();
        maxheight=screen.getHeight();
        
        Application.setUserAgentStylesheet(null);//getClass().getResource("MainFrame.css")
        //.toExternalForm());
        
        this.window=primaryStage;
        scene=new Scene(root,prewidth,preheight);
        scene.getStylesheets().add(getClass().getResource("MainFrame.css").toExternalForm());
        String userdir=System.getProperty("user.dir");
        
        createContent();
        primaryStage.setScene(scene);
        primaryStage.show();
    }
    
    private Parent createContent(){
        content = new BorderPane();
        MenuBar menubar=new MenuBar();
        menubar.getMenus().add(new Menu("File"));
        
        SplitPane split=new SplitPane();
        split.setOrientation(Orientation.HORIZONTAL);
        
        VBox left=new VBox();
        left.getStyleClass().add("leftbg"); 
        //left.setPrefWidth(100);
        Button btn=new Button("Click");
        btn.getStyleClass().add("button1"); 
        left.getChildren().add(btn);
        //left.setPrefWidth(200);
        BorderPane right=new BorderPane();
        split.getItems().addAll(left,right);
        split.setDividerPositions(0.1f,0.9f);
        content.prefHeightProperty().bind(scene.heightProperty());
        content.prefWidthProperty().bind(scene.widthProperty());
        content.setTop(menubar);
        content.setCenter(split);
        //content.getStyleClass().add("leftbg"); 
        root.getChildren().removeAll();
        root.getChildren().addAll(content);

        return root;
    }

    public static void main(String[] args) {
        launch(args);
    }
}
